//---------------------------------------------------------------------------------
#include "CMapReader.h"
//---------------------------------------------------------------------------------
void CMapReader::createMap(CMap *map, QString level) {
	int x, y, i;
	CCase *c=0;
	
	map->clean();
	
	for(i=x=y=0;i<level.size();i++) {
		switch(level[i].toAscii()) {
			case '\n':
				x=0;
				y++;
			case '\r':
				continue;
			case ' ':
				c=new CCase(x, y, CCase::ectVide);
				break;
			case '#':
				c=new CCase(x, y, CCase::ectMur);
				break;
			case '$':
				c=new CCase(x, y, CCase::ectVide);
				c->setHasCaisse(true);
				break;
			case '.':
				c=new CCase(x, y, CCase::ectVide);
				c->setHasEmplacement(true);
				break;
			case '*':
				c=new CCase(x, y, CCase::ectVide);
				c->setHasEmplacement(true);
				c->setHasCaisse(true);
				break;
			case '+':
				c=new CCase(x, y, CCase::ectVide);
				map->setPlayerPos(x, y);
				c->setHasEmplacement(true);
				break;
			case '@':
				c=new CCase(x, y, CCase::ectVide);
				map->setPlayerPos(x, y);
				break;
			default:
				return;
		}
		map->addCase(c);
		x++;
	}
}
//---------------------------------------------------------------------------------